import time
import multiprocessing as mp


def reader(q):
    while True:
        data = q.get()
        if data == 'exit':
            break
        print('read from the queque: %s' % data)


def writer(q):
    for i in range(10):
        q.put(i)
        time.sleep(0.2)
    q.put('exit')


if __name__ == '__main__':
    q = mp.Queue(100)
    reader = mp.Process(target=reader, args=(q,))
    writer = mp.Process(target=writer, args=(q,))
    writer.start()
    reader.start()
    reader.join()
    writer.join()
